﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace EvertonApp.Transporte
{
    [DataContract]
    public class Comercio
    {
        [DataMember]
        public Guid IdComercio { get; set; }
        [DataMember]
        public String Nombre { get; set; }
        [DataMember]
        public String Direccion { get; set; }
        [DataMember]
        public String Telefono { get; set; }
        [DataMember]
        public List<Oferta> Ofertas { get; set; }

        public Comercio()
        {
        }

        public Comercio(string json)
        {
            JObject jObject = JObject.Parse(json);
            JToken jComercio = jObject["Comercio"];
            IdComercio = (Guid)jComercio["IdComercio"];
            Nombre = (String)jComercio["Nombre"];
            Direccion = (String)jComercio["Direccion"];
            Telefono = (String)jComercio["Telefono"];
        }

        public Comercio(Guid id, String nom, String dir, String tel)
        {
            this.IdComercio = id;
            this.Nombre = nom;
            this.Direccion = dir;
            this.Telefono = tel;
        }
    }

    [DataContract]
    public class Comercios
    {
        [DataMember]
        public List<Comercio> Comercio { get; set; }
    }

}
